home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / pxewin.zip / PXSCROLL.CPP < prev    next >
Text File  |  1992-02-07  |  5KB  |  172 lines

  1. // PXEWIN - (C) Copyright 1992 by Beam Engineering, INC.
  2.  
  3. // PXSCROLL.CPP //
  4.  
  5. // Contents ----------------------------------------------------------------
  6. //
  7. //    This module contains members for the PXScroller class.
  8. //
  9. // End ---------------------------------------------------------------------
  10.  
  11. // External Reference Name for this Header ---------------------------------
  12.  
  13. #ifndef PXSCROLL_CPP
  14.     #define PXSCROLL_CPP
  15.  
  16. // End ---------------------------------------------------------------------
  17.  
  18. // Interface Dependencies --------------------------------------------------
  19.  
  20. #ifndef PXSCROLL_HPP
  21.     #include "pxscroll.hpp"
  22. #endif // PXSCROLL_HPP //
  23.  
  24. // End ---------------------------------------------------------------------
  25.  
  26. // member VScroll of PXScroller //
  27.  
  28. void PXScroller::VScroll(WORD ScrollEvent,int ThumbPos)
  29. {
  30.     // In case the number of records changes.
  31.  
  32.     my_display->my_table->NumRecs();
  33.     SetRange(my_display->RetSum(),
  34.         my_display->EngDataPtr->num_recs - 1);
  35.  
  36.     switch(ScrollEvent)
  37.     {
  38.         case SB_LINEDOWN:
  39.         {
  40.             my_display->IncRec();
  41.             break;
  42.         }
  43.         case SB_LINEUP:
  44.         {
  45.             my_display->DecRec();
  46.             break;
  47.         }
  48.         case SB_THUMBPOSITION:
  49.         {
  50.             YPos = ThumbPos;
  51.             my_display->FillBoxes(YPos + 1 - my_display->item);
  52.             break;
  53.         }
  54.         case SB_PAGEDOWN:
  55.         {
  56.             my_display->FillBoxes(my_display->top_rec +
  57.                 PAGE_SIZE);
  58.             break;
  59.         }
  60.         case SB_PAGEUP:
  61.         {
  62.             my_display->FillBoxes(my_display->top_rec -
  63.                 PAGE_SIZE);
  64.             break;
  65.         }
  66.     }
  67.  
  68.     // Scroll bars should reflect current database position.
  69.  
  70.     YPos = my_display->RetCurRec() - 1;
  71.  
  72.     // EndView will set the scroller to the desired position
  73.  
  74.     EndView();
  75. }
  76.  
  77. // Summary -----------------------------------------------------------------
  78. //
  79. //    Redefine vertical scroll bars to allow scrolling through a table.
  80. //
  81. // Parameters
  82. //
  83. //    ScrollEvent.  This is the scroll event parameters.
  84. //
  85. //    Thumbpos.  The thumb position of the scroll bar.
  86. //
  87. // Return Value
  88. //
  89. //    None.
  90. //
  91. // Functional Description
  92. //
  93. //    Each vertical scroll event is redefined here.  Each increment of
  94. //    YPos cooresponds to one record in the database.  First check and
  95. //    make sure the range is set according to the number of records in
  96. //    the table.
  97. //
  98. //    The following is a summary of the scrolling events and how they are
  99. //    handled:
  100. //
  101. //    SB_LINEDOWN.  Increment YPos.  Call your display increment
  102. //    record routine.
  103. //
  104. //    SB_LINEUP.  Decrement YPos.  Call your display decrement record
  105. //    routine.
  106. //
  107. //    SB_THUMBPOSITION.  Set YPos to thumb position.  Call your display
  108. //    routine for filling the boxes.  Record position starts with record
  109. //    1 so you have to add 1 to the YPos to get the record number.
  110. //
  111. //      SB_PAGEDOWN.  Add the page size to YPos.  Call your display routine
  112. //    for filling the boxes.
  113. //
  114. //    SB_PAGEUP.  Subtract the page size from YPos.  Call you display
  115. //    routine for filling the boxes.
  116. //
  117. //
  118. //    You will notice that we have not done any range checks on YPos.
  119. //    Range checking is done in the display routine (see DBDISPLAY).
  120. //    So we call the display routine to give us the current record for
  121. //    YPos.  This will be range checked.  Then we can call EndView to set
  122. //    the final scroll position.
  123. //
  124. // End ---------------------------------------------------------------------
  125.  
  126. // member build of PXScroller //
  127.  
  128. PTStreamable PXScroller::build()
  129. {
  130.     return new PXScroller(streamableInit);
  131. }
  132.  
  133. TStreamableClass RegPXScroller("PXScroller",PXScroller::build,
  134.     __DELTA(PXScroller));
  135.  
  136. // Description -------------------------------------------------------------
  137. //
  138. //    When the streamable constructor is called, TStreamable dispatches
  139. //    the build member to construct the object.  To do this, it must
  140. //    know where to find this member functions for the specific class.
  141. //    This is the reason for the stream registration.
  142. //
  143. // End ---------------------------------------------------------------------
  144.  
  145. // member read of PXScroller //
  146.  
  147. inline Pvoid PXScroller::read(Ripstream is)
  148. {
  149.     TScroller::read(is);
  150.     return this;
  151. }
  152.  
  153. // Summary -----------------------------------------------------------------
  154. //
  155. //    Call the TScroller read member.
  156. //
  157. // End ---------------------------------------------------------------------
  158.  
  159. // member write of PXScroller //
  160.  
  161. inline void PXScroller::write(Ropstream os)
  162. {
  163.     TScroller::write(os);
  164. }
  165.  
  166. // Summary -----------------------------------------------------------------
  167. //
  168. //    Call the TScroller Write member.
  169. //
  170. // End ---------------------------------------------------------------------
  171.  
  172. #endif // PXSCROLL_CPP //